import {
  ViewController,
  ITreeGridViewEvent,
  ITreeGridViewState,
} from '@ibiz-template/runtime';
import { IAppDETreeGridView } from '@ibiz/model-core';
import { GridViewEngine } from './grid-view.engine';

export class TreeGridViewEngine extends GridViewEngine {
  protected declare view: ViewController<
    IAppDETreeGridView,
    ITreeGridViewState,
    ITreeGridViewEvent
  >;

  /**
   * 多数据部件名称
   *
   * @author zk
   * @date 2023-10-07 06:10:44
   * @readonly
   * @type {string}
   * @memberof TreeGridViewEngine
   */
  get xdataControlName(): string {
    return 'treegrid';
  }

  async onCreated(): Promise<void> {
    await super.onCreated();
    if (!this.view.slotProps.treegrid) {
      this.view.slotProps.treegrid = this.view.slotProps.grid;
    } else {
      Object.assign(this.view.slotProps.treegrid, this.view.slotProps.grid);
    }
  }
}
